﻿using NLog;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BatchJob.Job.Order
{
    /// <summary>
    /// 预售订单尾款支付提醒
    /// </summary>
    [DisallowConcurrentExecution]
    public class AdvanceSaleOrderRestPayNotify : IBaseJob
    {
        private static Logger logger = LogManager.GetCurrentClassLogger();

        public string InKeyValue { get; set; }

        public void Run()
        {
            string type = InKeyValue;
            try
            {
                logger.Info("{0}执行成功:[BatchJobType:{1}]", typeof(AdvanceSaleOrderRestPayNotify), type.ToString());
            }
            catch (Exception ex)
            {
                logger.Error("{0}执行出错:{1}[BatchJobType:{2}]", typeof(AdvanceSaleOrderRestPayNotify), ex.Message, type.ToString());
            }
        }

        public void Execute(IJobExecutionContext context)
        {
            try
            {
                InKeyValue = context.JobDetail.JobDataMap["InKey"].ToString();
                logger.Debug("调用成功！[Description:{0}][FullName:{1}][InKeyValue:{2}]", context.JobDetail.Description, context.JobDetail.JobType.FullName, InKeyValue);
                Run();
            }
            catch (Exception ex)
            {
                logger.Error("调用出错！[Description:{0}][FullName:{1}][ex.Message:{2}]", context.JobDetail.Description, context.JobDetail.JobType.FullName, ex.Message);
            }
        }
    }
}
